package com.leyou.trade.web;


import com.leyou.trade.dto.OrderDTO;
import com.leyou.trade.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class OrderController {


    @Autowired
    private OrderService orderService;

    /**
     * todo 下单  (保存订单等信息到数据库)
     * @param orderDTO
     * @return
     */
    @PostMapping
    public ResponseEntity<Long> crateOrder(@RequestBody OrderDTO orderDTO){


        System.out.println(orderDTO);

      // ;
        return ResponseEntity.status(HttpStatus.CREATED).body(this.orderService.crateOrder(orderDTO));



    }






}
